package com.zlsy.springbootdemo.state.demo1;

/**
 * @author zhouliang
 * @date 2021/1/23 13:03 定义一个上下文管理环境
 */
public class Context {
  public static final ConcreteStateA CONCRETE_STATE_A = new ConcreteStateA();
  public static final ConcreteStateB CONCRETE_STATE_B = new ConcreteStateB();
  private State currentState;

  public State getCurrentState() {
    return currentState;
  }

  public void setCurrentState(State currentState) {
    this.currentState = currentState;
    this.currentState.setContext(this);
  }

  public void handle1() {
    this.currentState.handle1();
  }

  public void handle2() {
    this.currentState.handle2();
  }
}
